package com.example.xlmkotlinwanandroid.learn

/**
 *  author : cailei
 *  date : 2022/3/10
 *  description :
 */
abstract class BaseSingleClass<P, T> {

    @Volatile
    private var INSTANCE: T? = null

    fun getInstance(params: P): T = INSTANCE ?: synchronized(this) {
        INSTANCE ?: createInstance(params).also { INSTANCE = it }
    }


    abstract fun createInstance(params: P): T
}